/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package forms;

import DAO.FornecedorDAO;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import model.Fornecedor;

public class frmFornecedores extends javax.swing.JFrame {

    boolean alterar = false;

    public frmFornecedores() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jRadioButton1 = new javax.swing.JRadioButton();
        jProgressBar1 = new javax.swing.JProgressBar();
        buttonGroup1 = new javax.swing.ButtonGroup();
        TabPai = new javax.swing.JTabbedPane();
        TabListagem = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabFornecedor = new javax.swing.JTable();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel17 = new javax.swing.JLabel();
        txtBuscaNome = new javax.swing.JTextField();
        btnBuscar = new javax.swing.JButton();
        btnNovo = new javax.swing.JButton();
        btnDeletar = new javax.swing.JButton();
        btnAlterar = new javax.swing.JButton();
        TabCadastro = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtNomeFantasia = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtRasaoSocial = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtCNPJ = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtInscMunicipal = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txtEndereco = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        txtNumero = new javax.swing.JTextField();
        txtComplemento = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtBairro = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtCidade = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txtCep = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        txtUF = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtContato = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtTelefone1 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        txtTelefone2 = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        txtSite = new javax.swing.JTextField();
        btnGravar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        lblCodigo = new javax.swing.JLabel();
        radAtivo = new javax.swing.JRadioButton();
        radInativo = new javax.swing.JRadioButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();

        jRadioButton1.setText("jRadioButton1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMaximumSize(new java.awt.Dimension(800, 401));
        setMinimumSize(new java.awt.Dimension(800, 401));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        TabPai.setPreferredSize(new java.awt.Dimension(700, 600));

        TabListagem.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        tabFornecedor.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Código:", "Nome:", "CNPJ:", "Telefone:", "E-mail:"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tabFornecedor);

        TabListagem.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, 780, 256));
        TabListagem.add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, 800, 10));

        jLabel17.setText("Nome/Razão Social:");
        TabListagem.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));
        TabListagem.add(txtBuscaNome, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, 236, -1));

        btnBuscar.setText("Buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });
        TabListagem.add(btnBuscar, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 10, -1, 40));

        btnNovo.setText("Novo");
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });
        TabListagem.add(btnNovo, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 330, 140, 25));

        btnDeletar.setText("Deletar");
        btnDeletar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeletarActionPerformed(evt);
            }
        });
        TabListagem.add(btnDeletar, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 330, 140, 25));

        btnAlterar.setText("Alterar");
        btnAlterar.setPreferredSize(new java.awt.Dimension(57, 23));
        btnAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAlterarActionPerformed(evt);
            }
        });
        TabListagem.add(btnAlterar, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 330, 140, 25));

        TabPai.addTab("Listagem", TabListagem);

        TabCadastro.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setText("Nome Fantasia:");
        TabCadastro.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 14, -1, -1));
        TabCadastro.add(txtNomeFantasia, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 11, 532, -1));

        jLabel2.setText("Razão Social:");
        TabCadastro.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(21, 45, -1, -1));
        TabCadastro.add(txtRasaoSocial, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 42, 532, -1));

        jLabel4.setText("CNPJ:");
        TabCadastro.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(56, 76, -1, -1));
        TabCadastro.add(txtCNPJ, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 73, 164, -1));

        jLabel5.setText("Insc. Mun.:");
        TabCadastro.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(404, 76, -1, -1));
        TabCadastro.add(txtInscMunicipal, new org.netbeans.lib.awtextra.AbsoluteConstraints(469, 73, 158, -1));

        jLabel7.setText("Endereço:");
        TabCadastro.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(36, 107, -1, -1));
        TabCadastro.add(txtEndereco, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 104, 532, -1));

        jLabel8.setText("Número:");
        TabCadastro.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(44, 137, -1, -1));
        TabCadastro.add(txtNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 134, 164, -1));
        TabCadastro.add(txtComplemento, new org.netbeans.lib.awtextra.AbsoluteConstraints(467, 134, 160, -1));

        jLabel9.setText("Complemento:");
        TabCadastro.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(388, 137, -1, -1));
        TabCadastro.add(txtBairro, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 165, 164, -1));

        jLabel10.setText("Bairro:");
        TabCadastro.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(53, 168, -1, -1));

        jLabel6.setText("Cidade:");
        TabCadastro.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 170, -1, -1));
        TabCadastro.add(txtCidade, new org.netbeans.lib.awtextra.AbsoluteConstraints(467, 165, 160, -1));

        jLabel11.setText("CEP:");
        TabCadastro.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(62, 199, -1, -1));
        TabCadastro.add(txtCep, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 196, 164, -1));

        jLabel12.setText("UF:");
        TabCadastro.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 200, -1, -1));
        TabCadastro.add(txtUF, new org.netbeans.lib.awtextra.AbsoluteConstraints(467, 196, 160, -1));

        jLabel3.setText("Contato:");
        TabCadastro.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(42, 230, -1, -1));
        TabCadastro.add(txtContato, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 227, 532, -1));

        jLabel13.setText("Telefone 1:");
        TabCadastro.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 260, -1, -1));
        TabCadastro.add(txtTelefone1, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 258, 164, -1));

        jLabel14.setText("Telefone 2:");
        TabCadastro.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(395, 261, -1, -1));
        TabCadastro.add(txtTelefone2, new org.netbeans.lib.awtextra.AbsoluteConstraints(468, 258, 160, -1));

        jLabel15.setText("E-mail:");
        TabCadastro.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(53, 292, -1, -1));
        TabCadastro.add(txtEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 289, 164, -1));

        jLabel16.setText("Site:");
        TabCadastro.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(436, 292, -1, -1));
        TabCadastro.add(txtSite, new org.netbeans.lib.awtextra.AbsoluteConstraints(468, 289, 160, -1));

        btnGravar.setText("Salvar");
        btnGravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGravarActionPerformed(evt);
            }
        });
        TabCadastro.add(btnGravar, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 360, 113, -1));

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });
        TabCadastro.add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 360, 113, -1));

        lblCodigo.setText("0");
        lblCodigo.setEnabled(false);
        TabCadastro.add(lblCodigo, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        buttonGroup1.add(radAtivo);
        radAtivo.setText("Ativo");
        TabCadastro.add(radAtivo, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 320, -1, -1));

        buttonGroup1.add(radInativo);
        radInativo.setText("Inativo");
        TabCadastro.add(radInativo, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 320, -1, -1));

        TabPai.addTab("Cadastro", TabCadastro);

        jMenu1.setText("Fechar");
        jMenu1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu1MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TabPai, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(TabPai, javax.swing.GroupLayout.PREFERRED_SIZE, 428, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-816)/2, (screenSize.height-467)/2, 816, 467);
    }// </editor-fold>//GEN-END:initComponents
    public void atualizagrid() {
        DefaultTableModel modelo = (DefaultTableModel) tabFornecedor.getModel();
        modelo.setNumRows(0);
        try {
            FornecedorDAO dao = new FornecedorDAO();
            for (Fornecedor f : dao.findGrid()) {

                modelo.addRow(
                        new String[]{
                            "" + f.getCodigo(),
                            f.getRazaoSocial(),
                            f.getCnpj(),
                            f.getTelefone(),
                            f.getEmail()});
            }
        } catch (Exception ex) {
        }
    }
    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        alterar = false;
        lblCodigo.setVisible(false);
        radAtivo.setSelected(true);
        atualizagrid();
    }//GEN-LAST:event_formWindowOpened

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        lblCodigo.setText("0");
        txtNomeFantasia.setText("");
        txtRasaoSocial.setText("");
        txtContato.setText("");
        txtCNPJ.setText("");
        txtInscMunicipal.setText("");
        txtEndereco.setText("");
        txtNumero.setText("");
        txtComplemento.setText("");
        txtBairro.setText("");
        txtCidade.setText("");
        txtCep.setText("");
        txtUF.setText("");
        txtTelefone1.setText("");
        txtTelefone2.setText("");
        txtEmail.setText("");
        txtSite.setText("");
        TabPai.setSelectedIndex(0);
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGravarActionPerformed
        if (txtNomeFantasia.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo Nome Fantasia É Necessário!");
            txtNomeFantasia.requestFocus();
        }
        else if (txtRasaoSocial.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo Razão Social É Necessário!");
            txtRasaoSocial.requestFocus();
        }
        else if (txtCNPJ.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo CNPJ É Necessário!");
            txtCNPJ.requestFocus();
        }
        else if (txtEndereco.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo Endereço É Necessário!");
            txtEndereco.requestFocus();
        }
        else if (txtNumero.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo Número É Necessário!");
            txtNumero.requestFocus();
        }
        else if (txtBairro.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo Bairro É Necessário!");
            txtBairro.requestFocus();
        }
        else if (txtCidade.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo Cidade É Necessário!");
            txtCidade.requestFocus();
        }
        else if (txtCep.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo CEP É Necessário!");
            txtCep.requestFocus();
        }
        else if (txtUF.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo UF É Necessário!");
            txtUF.requestFocus();
        }
        else if (txtTelefone1.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Campo Telefone É Necessário!");
            txtTelefone1.requestFocus();
        }
        else{
            try {
                int FRN_ID = Integer.parseInt(lblCodigo.getText());
                String FRN_NOMEFANTASIA = txtNomeFantasia.getText();
                String FRN_RAZAOSOCIAL = txtRasaoSocial.getText();
                String FRN_PESSOACONTATO = txtContato.getText();
                String FRN_CNPJ = txtCNPJ.getText();
                String FRN_INSCMUNICIPAL = (txtInscMunicipal.getText());
                Date FRN_DATACADASTRO = new Date();
                String FRN_ENDERECO = (txtEndereco.getText());
                int FRN_NUMERO = "".equals(txtNumero.getText()) ? 0 : Integer.parseInt(txtNumero.getText());
                String FRN_COMPLEMENTO = (txtComplemento.getText());
                String FRN_BAIRRO = (txtBairro.getText());
                String FRN_CIDADE = (txtCidade.getText());
                String FRN_CEP = (txtCep.getText());
                String FRN_UF = (txtUF.getText());
                String FRN_TELEFONE = (txtTelefone1.getText());
                String FRN_TELEFONEALTERNATIVO = (txtTelefone2.getText());
                String FRN_EMAIL = (txtEmail.getText());
                String FRN_SITE = (txtSite.getText());
                boolean FRN_STATUS;
                if (radAtivo.isSelected()) {
                    FRN_STATUS = true;
                } else {
                    FRN_STATUS = false;
                }
                Fornecedor forn = new Fornecedor();
                forn.setCodigo(FRN_ID);
                forn.setNomeFantasia(FRN_NOMEFANTASIA);
                forn.setRazaoSocial(FRN_RAZAOSOCIAL);
                forn.setPessoaContato(FRN_PESSOACONTATO);
                forn.setCnpj(FRN_CNPJ);
                forn.setInscMunicipal(FRN_INSCMUNICIPAL);
                forn.setDataCadastro(FRN_DATACADASTRO);
                forn.setEndereco(FRN_ENDERECO);
                forn.setNumero(FRN_NUMERO);
                forn.setComplemento(FRN_COMPLEMENTO);
                forn.setBairro(FRN_BAIRRO);
                forn.setCidade(FRN_CIDADE);
                forn.setCep(FRN_CEP);
                forn.setUf(FRN_UF);
                forn.setTelefone(FRN_TELEFONE);
                forn.setTelefoneAlternativo(FRN_TELEFONEALTERNATIVO);
                forn.setEmail(FRN_EMAIL);
                forn.setSite(FRN_SITE);
                forn.setStatus(FRN_STATUS);
                FornecedorDAO dao = new FornecedorDAO();
                if (alterar == false) {
                    dao.insert(forn);
                    JOptionPane.showMessageDialog(this, "Fornecedor Salvo!");
                } else {
                    dao.update(forn);
                    JOptionPane.showMessageDialog(this, "Fornecedor Alterado!");
                }

            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            }

            txtNomeFantasia.setText("");
            txtRasaoSocial.setText("");
            txtContato.setText("");
            txtCNPJ.setText("");
            txtInscMunicipal.setText("");
            txtEndereco.setText("");
            txtNumero.setText("");
            txtComplemento.setText("");
            txtBairro.setText("");
            txtCidade.setText("");
            txtCep.setText("");
            txtUF.setText("");
            txtTelefone1.setText("");
            txtTelefone2.setText("");
            txtEmail.setText("");
            txtSite.setText("");
            TabPai.setSelectedIndex(0);
            atualizagrid();
        }
    }//GEN-LAST:event_btnGravarActionPerformed

    private void btnAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAlterarActionPerformed
        alterar = true;

        String codigo = "" + tabFornecedor.getValueAt(tabFornecedor.getSelectedRow(), 0);
        try {
            FornecedorDAO DAO = new FornecedorDAO();
            Fornecedor f = DAO.findByCodigo(Integer.parseInt(codigo));
            lblCodigo.setText(codigo);

            txtNomeFantasia.setText(f.getNomeFantasia());
            txtRasaoSocial.setText(f.getRazaoSocial());
            txtContato.setText(f.getPessoaContato());
            txtCNPJ.setText(f.getCnpj());
            txtInscMunicipal.setText(f.getInscMunicipal());
            txtEndereco.setText(f.getEndereco());
            txtNumero.setText(String.valueOf(f.getNumero()));
            txtComplemento.setText(f.getComplemento());
            txtBairro.setText(f.getBairro());
            txtCidade.setText(f.getCidade());
            txtCep.setText(f.getCep());
            txtUF.setText(f.getUf());
            txtTelefone1.setText(f.getTelefone());
            txtTelefone2.setText(f.getTelefoneAlternativo());
            txtEmail.setText(f.getEmail());
            txtSite.setText(f.getSite());
            if (f.isStatus()) {
                radAtivo.setSelected(true);
            } else {
                radInativo.setSelected(true);
            }
        } catch (Exception ex) {
            Logger.getLogger(frmUnidadeMedida.class.getName()).log(Level.SEVERE, null, ex);
        }
        atualizagrid();
        TabPai.setSelectedIndex(1);
    }//GEN-LAST:event_btnAlterarActionPerformed

    private void btnDeletarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeletarActionPerformed
        String codigo = "" + tabFornecedor.getValueAt(tabFornecedor.getSelectedRow(), 0);
        try {
            FornecedorDAO DAO = new FornecedorDAO();
            DAO.delete(Integer.parseInt(codigo));
        } catch (Exception ex) {
            Logger.getLogger(frmUnidadeMedida.class.getName()).log(Level.SEVERE, null, ex);
        }
        atualizagrid();
    }//GEN-LAST:event_btnDeletarActionPerformed

    private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
        alterar = false;
        TabPai.setSelectedIndex(1);
    }//GEN-LAST:event_btnNovoActionPerformed

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        DefaultTableModel modelo = (DefaultTableModel) tabFornecedor.getModel();
        modelo.setNumRows(0);
        try {
            FornecedorDAO dao = new FornecedorDAO();
            for (Fornecedor f : dao.findByNome(txtBuscaNome.getText())) {

                modelo.addRow(
                    new String[]{
                        "" + f.getCodigo(),
                        f.getRazaoSocial(),
                        f.getCnpj(),
                        f.getTelefone(),
                        f.getEmail()});
            }
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void jMenu1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu1MouseClicked
this.dispose();
    }//GEN-LAST:event_jMenu1MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;


                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmFornecedores.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmFornecedores.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmFornecedores.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmFornecedores.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmFornecedores().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel TabCadastro;
    private javax.swing.JPanel TabListagem;
    private javax.swing.JTabbedPane TabPai;
    private javax.swing.JButton btnAlterar;
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnDeletar;
    private javax.swing.JButton btnGravar;
    private javax.swing.JButton btnNovo;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JLabel lblCodigo;
    private javax.swing.JRadioButton radAtivo;
    private javax.swing.JRadioButton radInativo;
    private javax.swing.JTable tabFornecedor;
    private javax.swing.JTextField txtBairro;
    private javax.swing.JTextField txtBuscaNome;
    private javax.swing.JTextField txtCNPJ;
    private javax.swing.JTextField txtCep;
    private javax.swing.JTextField txtCidade;
    private javax.swing.JTextField txtComplemento;
    private javax.swing.JTextField txtContato;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtEndereco;
    private javax.swing.JTextField txtInscMunicipal;
    private javax.swing.JTextField txtNomeFantasia;
    private javax.swing.JTextField txtNumero;
    private javax.swing.JTextField txtRasaoSocial;
    private javax.swing.JTextField txtSite;
    private javax.swing.JTextField txtTelefone1;
    private javax.swing.JTextField txtTelefone2;
    private javax.swing.JTextField txtUF;
    // End of variables declaration//GEN-END:variables
}
